package com.emm.yixun.config;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

public class DsfConfig{

	public static boolean validSign(Object object) {
		boolean validState = false;
		String encryptBunch = "";
		Map<String, String> signMap = new HashMap<String, String>();
		try {
			signMap = EncryptUtil.toMap(object);
			String sign = signMap.get("sign");
			signMap.remove("sign");
			//把数组所有元素排序，并按照“参数=参数值”的模式用“&”字符拼接成字符串
			String validBunch = EncryptUtil.createLinkString(signMap);
			//对字符串加密,加密算法使用MD5
			encryptBunch = EncryptUtil.Encrypt(validBunch, "MD5");
			if (encryptBunch.equals(sign)) {
				validState = true;
			}
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (IntrospectionException e) {
			e.printStackTrace();
		}
		return validState;
	}
}
